<template>
  <div class="Feedback_record">
    <c-title :hide="false" text="意见反馈"></c-title>
    <div class="list">
      <div class="lis" v-for="item in dataList" :key="item.id" @click="toDetail(item.id)">
        <div class="lis_l">
          <div class="title" v-if="item.diyform_type">{{ item.diyform_type.title }}</div>
          <div class="lis_bottom_r">填写时间：{{ item.created_at }}</div>
        </div>
        <i class="iconfont icon-icon_more11"></i>
      </div>
    </div>
  </div>
</template>
<script>
import { scrollMixin } from "utils/mixin";
export default {
  mixins: [scrollMixin],
  data() {
    return {
      page: 1,
      total_page: 0,
      isLoadMore: true,
      dataList: []
    };
  },
  activated() {
    this.init();
    this.getData();
  },
  methods: {
    toDetail(id) {
      this.$router.push(this.fun.getUrl("formDetail", { id: id }));
    },
    init() {
      this.page = 1;
      this.total_page = 0;
      this.isLoadMore = true;
    },
    async getData() {
      let { data, msg, result } = await $http.post("plugin.diyform.api.diy-form.selfFormList", { form_id: this.$route.params.id }, "");
      if (result) {
        this.dataList = data.data;
        this.total_page = data.last_page;
        this.isLoadMore = true;
      } else {
        this.$toast(msg);
      }
    },
    async getMoreData() {
      if (!this.isLoadMore) return;
      this.isLoadMore = false; // 防止多次请求分页数据
      if (this.page >= this.total_page) {
        return;
      } else {
        this.page += 1;
        let json = {
          page: this.page,
          form_id: this.$route.params.id
        };
        let { data, msg, result } = await $http.post("plugin.diyform.api.diy-form.selfFormList", json, "");
        this.isLoadMore = true;
        if (result) {
          this.dataList = this.dataList.concat(data.data);
        } else {
          this.page = this.page - 1;
          this.$toast(msg);
        }
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.list {
  margin: 0.63rem 0.75rem;
  .lis {
    padding: 0.94rem 0.63rem;
    box-sizing: border-box;
    background: #fff;
    border-radius: 0.5rem;
    margin-bottom: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .lis_l {
      text-align: left;
      .title {
        font-weight: 500;
        font-size: 0.94rem;
        color: #00001c;
        margin-bottom: 0.81rem;
        text-align: left;
      }

      .lis_bottom {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.81rem;
        color: #999999;
      }
    }
    .icon-icon_more11 {
      color: #aaaab3;
    }
  }
}
</style>
